#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2021/9/17 14:35
# @Author : lenovo
# @Email : 26541796406@qq.com
# @File : MRYX_SEARCH_002.py
# @Project : mryx_test
"""验证地址新增功能—正确输入所有信息"""
from appium import webdriver
from time import sleep
from appium.webdriver.common.mobileby import MobileBy as By
desired_capabilites = {
    "platformName":"Android",
    "deviceName":"5ENDU19222007479",
    "platformVersion":"10",
    "appPackage":"cn.missfresh.application",
    "appActivity":"cn.missfresh.module.main.view.SplashActivity",
    "noReset":True,
    "resetKeyboard":True
}
driver = webdriver.Remote('http://localhost:4723/wd/hub',desired_capabilites)
sleep(5)
driver.find_element(By.ID,'cn.missfresh.application:id/address_tv').click()  #点击定位
sleep(1)
driver.find_element(By.ID,'cn.missfresh.application:id/tv_title_bar_right_txt').click()  #点击新增地址
sleep(2)
driver.find_element(By.ID,'cn.missfresh.application:id/et_edit_address_receiver').clear()  # 清除收货人
sleep(2)
driver.find_element(By.ID,'cn.missfresh.application:id/et_edit_address_receiver').send_keys('李嫣')  # 输入收货人
driver.hide_keyboard()
sleep(1)
driver.find_element(By.ID,'cn.missfresh.application:id/et_edit_address_tel').clear()  #清空手机号
sleep(1)
driver.find_element(By.ID,'cn.missfresh.application:id/et_edit_address_tel').send_keys('17712349875')  #输入手机号
driver.hide_keyboard()
driver.find_element(By.ID,'cn.missfresh.application:id/tv_edit_detail_address').click() #点击收货地址进入搜索地址地址页面
sleep(2)
driver.find_element(By.XPATH,'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.' 
                             'FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.'
                             'LinearLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.'
                             'LinearLayout/android.widget.LinearLayout/android.widget.TextView[2]').click()   #点击搜索
driver.find_element(By.ID,'cn.missfresh.application:id/et_search_address_input').click()  #再点击一次
driver.find_element(By.ID,'cn.missfresh.application:id/et_search_address_input').send_keys('东方广场c座') # 输入地址
driver.hide_keyboard()
driver.find_element(By.XPATH,'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.'
                             'FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.'
                             'LinearLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.'
                             'FrameLayout/android.widget.RelativeLayout/android.widget.ListView/android.widget.'
                             'FrameLayout[1]/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.'
                             'TextView[1]').click() # 点击第一个
driver.find_element(By.ID,'cn.missfresh.application:id/et_edit_doorplate').click() # 点击楼号门牌
driver.find_element(By.ID,'cn.missfresh.application:id/et_edit_doorplate').send_keys('七楼')  # 输入七楼
driver.hide_keyboard()
driver.find_element(By.ID,'cn.missfresh.application:id/btn_save_address').click() # 点击保存